// import { AxiosPromise } from 'axios'
import request from '../utils/request'

export default {
  /**
   * 获取所有的分类树
   * @param option 查询条件
   * @returns {AxiosPromise} Promise
   */
  getCategoryTree (option) {
    return request({
      url: '/item/category/tree',
      method: 'get',
      params: option
    })
  },
  // slide
  getSlideList (option) {
    return request({
      url: '/slide/web',
      method: 'get',
      params: option
    })
  },

  // 行业动态
  getDevelopmentList (option) {
    return request({
      url: '/development/index',
      method: 'get',
      params: option
    })
  },
  // 首页项目展示
  getItemPage (option) {
    return request({
      url: '/items/page',
      method: 'get',
      params: option
    })
  },

  // 网站公告
  getNoticePage (option) {
    return request({
      url: '/notice/index',
      method: 'get',
      params: option
    })
  },

  // 精品推荐
  getItemHot (option) {
    return request({
      url: '/items/hot',
      method: 'get',
      params: option
    })
  },

  getItemSearch (option) {
    // const { q } = option
    return request({
      url: '/items/search',
      method: 'post',
      data: {
        q: option.q,
        pageSize: option.pageSize || 10,
        currentPage: option.currentPage || 1,
        c: option.c,
        conditions: option.conditions
      }
    })
  },

  getAllConditions () {
    return request({
      url: '/item/condition/all',
      method: 'get'
    })
  },

  getCompanyJoin () {
    return request({
      url: '/join',
      method: 'get'
    })
  },

  getNews () {
    return request({
      url: '/news/news/web',
      method: 'get'
    })
  },

  getCategoryRecommend () {
    return request({
      url: '/item/category/web/recommend',
      method: 'get'
    })
  },

  getCategoryDetail (id) {
    return request({
      url: `/item/category/detail/${id}`,
      method: 'get'
    })
  },

  getAbout () {
    return request({
      url: '/about',
      method: 'get'
    })
  },

  getDevelopmentDetail (id) {
    return request({
      url: `/development/detail/${id}`,
      method: 'get'
    })
  },

  getAllDevelopment () {
    return request({
      url: '/development/list',
      method: 'get'
    })
  },

  getItemDetail (id) {
    return request({
      url: '/items/detail/' + id,
      method: 'get'
    })
  },

  getNewsList () {
    return request({
      url: '/news/news/list',
      method: 'get'
    })
  },

  getNewsDetail (id) {
    return request({
      url: '/news/news/detail/' + id,
      method: 'get'
    })
  },

  getNoticeDetail (id) {
    return request({
      url: '/notice/detail/' + id,
      method: 'get'
    })
  }

}
